<?php
/**
* 通用类别管理类
*/
namespace Admin\Controller;

class CategoryController extends CommonController{
	public  $exec_comfunc  = 'index,add,edit,delete';//index,add,edit,delete

	//添加
	public function add(){
		$type = $this->_get('type', '您的操作有误！');
		$this->assign('type', $type);
		parent::add('',$data,U('index', array('type' => $type)));
	}
	public function win_add(){
		if(IS_POST){
			$this->_post('title','名称不能为空！');
			$model = D('Category');
			if($form_data = $model->create()){
				$form_data['create_time'] = time();
				if(false !==$model->add($form_data)) {
					$data['add_id']    = $model->getLastInsID();
					$data['add_name']  = $form_data['title'];
	    		    $this->success('添加成功！', '', $data);
				}else{
					$this->error('添加失败！');
				}
			}else{
    			$this->error($model->getError());
    		}
		}
		$this->assign('type', $this->_get('type', '您的操作有误！'));
		$this->assign('category_field', $this->_get('category_field'));
		$this->display();
	}
	//修改
	public function edit(){
		$type = $this->_get('type', '您的操作有误！');
		$this->assign('type', $type);
		parent::edit('', $data, U('index', array('type' => $type)));
	}
	//列表
	public function index(){
		$type = $this->_get('type', '您的操作有误！');
		$where['module'] = $type;
		$this->assign('type', $type);
		$this->_boolean_field = array('no');
		parent::index('', $where, 'order_id,id desc');
	}
}
?>